 //网易严选
//api写接口的地方
//获取值得买轮播图数据
import requestSph from './request/request-sph'
import requestWy from './request/request-wy'
export const getBannerList = ()=>{
    return requestWy({
        url:'/topic/v1/know/navWap.json',
        method:'get'
    })
}
//获取轮播图瀑布流数据
export const getWaterWall = (page,size)=>requestWy.get(`/topic/v1/find/recAuto.json?page=${page}&size=${size}`)

// 分类页数据
export const getCenterList = () => {
    return requestWy({
        url: '/item/cateList.json?__timestamp=1630131286110&categoryId=',
        method: 'get'
    })
}

// 请求右侧数据
export const getCateList = (id) => {
    return requestWy({
        url: `item/cateList.json?__timestamp=1630131455012&categoryId=${id}`,
        method: 'get'
    })
}

// goodslist数据请求
export const getgoodsList = (subCategoryId, categoryId) => {
    return requestWy({
        url: `item/list.json?__timestamp=1630133942864&categoryType=0&subCategoryId=${subCategoryId}&categoryId=${categoryId}`,
        method: 'get'
    })
}

export const reqIndexData = ()=>{
    return requestWy({
        url:`/xhr/index.json?__timestamp=1630131808529`,
        method:'get'
    })
}

export const reqCardData =(categoryId)=>{
    return requestWy({
        url:`/item/list.json?__timestamp=1642484788204&categoryId=${categoryId}`,
        method:'get'
    })
}
// dyp
export {default as search} from './request/search'

// 请求详情页数据
export const reqDatilData = (id) => requestSph.get('/item/' + id)
// 请求添加到购物车
export const reqAddCart = (skuId, skuNum) => requestSph.post(`/cart/addToCart/${skuId}/${skuNum}`)
// 请求购物车中的数据
export const reqShopCartData = () => requestSph.get('/cart/cartList')
// 购物车商品是否选中
export const reqChangeCartSku = (skuID, isChecked) => requestSph.get(`/cart/checkCart/${skuID}/${isChecked}`)
// 批量删除购物车中的商品
export const deleteCarSkus = (skuId) => requestSph.delete(`/cart/deleteCart/${skuId}`)
//api写接口的地方

// 获取手机验证码
export function reqCode(phone) {
  return requestSph({
    url: `/user/passport/sendCode/${phone}`,
    method: "get",
  });
}

// 注册账号
export function reqRegister(user) {
  return requestSph({
    url: "/user/passport/register",
    method: "post",
    data: user,
  });
}

// 登录获取token
export const reqUserLogin = (user) => {
  return requestSph({
    url: "user/passport/login",
    method: "post",
    data: user,
  });
};

//根据token获取用户信息
export const reqGetUserInfo = () => {
  return requestSph({
    url: "/user/passport/auth/getUserInfo",
    method: "get",
  });
};

// 退出
export const reqUserLogout = () => {
  return requestSph({
    url: "/user/passport/logout",
    method: "get",
  });
};
